﻿using System;
using System.ComponentModel;
using SAFPodcast.WP8.DTO.Entities;

namespace SAFPodcast.WP8.DTO.TO
{
    public class FeedItem : INotifyPropertyChanged, INotifyPropertyChanging
    {
        public FeedItem()
        {
            IsDownloading = false;
        }
        public Feed Feed { get; set; }
        public Uri Uri { get; set; }
        public String Title { get; set; }
        public DateTime PublicationDate { get; set; }
        #region public bool IsDownloading { get; set; }
        private bool isDownloading;
        public bool IsDownloading
        {
            get
            {
                return isDownloading;
            }
            set
            {
                if (isDownloading != value)
                {
                    NotifyPropertyChanged("IsDownloading");
                    isDownloading = value;
                    NotifyPropertyChanging("IsDownloading");
                }
            }
        }
        #endregion
        #region public int DownloadProgress { get; set; }
        private int downloadProgress;
        public int DownloadProgress
        {
            get
            {
                return downloadProgress;
            }
            set
            {
                if (downloadProgress != value)
                {
                    NotifyPropertyChanged("DownloadProgress");
                    downloadProgress = value;
                    NotifyPropertyChanging("DownloadProgress");
                }
            }
        }
        #endregion
        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
        #region INotifyPropertyChanging Members
        public event PropertyChangingEventHandler PropertyChanging;
        private void NotifyPropertyChanging(string propertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
            }
        }
        #endregion
    }
}
